﻿using System;
using System.Windows;
using Microsoft.Win32;

namespace Reckoning
{
    /// <summary>
    /// Default implementation of file dialog service
    /// </summary>
    public class FileDialogService: IFileDialogService
    {
        private const string _defaultExt = ".xml";
        private string _filter;

        public FileDialogService()
        {
            _filter = Properties.Resources.FilterXml;
        }

        public string ReferenceFileDialog(bool save)
        {
            string ret = string.Empty;

            FileDialog dlg;
            if (save)
                dlg = new SaveFileDialog();
            else
                dlg = new OpenFileDialog();

            dlg.DefaultExt = _defaultExt;
            dlg.Filter = _filter;

            Nullable<bool> ok = dlg.ShowDialog();
            if (ok == true)
                ret = dlg.FileName;
            
            return ret;
        }

        public void ErrorMessageBox(string message)
        {
            MessageBox.Show(message); 
        }
    }
}
